package ls.test;

import ls.dao.DAOFactory;
import ls.dao.StudentDAO;
import ls.entity.Student;

import java.util.Scanner;

public class CreateStudent {
    public void createStudent(String student_id)
    {
        StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
        System.out.println("系统中未保存您的个人信息，请填写个人信息表：");
        String student_name="";
        String student_major="";
        String student_education="";
        String student_pwd = "null";
        String firstVol="null";
        String secondVol="null";
        String course="null";
        String state="未助教";
        String teacher="";
        int communicate_num = 0;
        int project_num = 0;
        Scanner scanner = new Scanner(System.in);
        System.out.print("登录密码：");
        student_pwd = scanner.next();
        System.out.print("研究生姓名：");
        student_name = scanner.next();
        System.out.print("研究生专业：");
        student_major = scanner.next();
        System.out.print("研究生学历：");
        student_education = scanner.next();
        System.out.print("导师：");
        teacher = scanner.next();
        System.out.println();
        Student addStu = new Student();
        addStu.setStudent_id(student_id);
        addStu.setStudent_pwd(student_pwd);
        addStu.setStudent_name(student_name);
        addStu.setStudent_major(student_major);
        addStu.setStudent_education(student_education);
        addStu.setTeacher(teacher);
        addStu.setState(state);
        addStu.setCourse(course);
        addStu.setFirstVol(firstVol);
        addStu.setSecondVol(secondVol);
        addStu.setCommunicate_num(communicate_num);
        addStu.setProject_num(project_num);
        studentDAO.addStudent(addStu);  // 如果研究生信息表中没有当前登录的这个研究生，那么让他填写个人信息，写入表中
        System.out.println("研究生信息添加成功！");
        System.out.println("若需进行助教志愿填报，请输入 1 ，");
        System.out.println("若需退出，请输入除 1 之外的随意数 ");
        Scanner scanner1 = new Scanner(System.in);
        int c = scanner1.nextInt();
        if(c == 1)
        {
            ChooseCourse chooseCourse = new ChooseCourse();
            chooseCourse.chooseCourse(student_id);
        }
        else return;
    }
}
